package exam.wangyi.spring.S1;

import java.util.*;

public class Main {

    public static int a;
    public static int b;
    public static int x;
    public static int y;
    public static int[][] dp;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        a = sc.nextInt();
        b = sc.nextInt();
        x = sc.nextInt();
        y = sc.nextInt();
        dp = new int[a+1][b+1];
        System.out.println(getMinTime());
    }

    public static int getMinTime() {
        int m = Math.max(x, y);
        for (int i=0; i<=a; ++i) {
            if (i % m == 0)
                dp[i][0] = i / m;
            else
                dp[i][0] = i / m + 1;
        }
        for (int j=1; j<=b; ++j) {
            if (j % m == 0)
                dp[0][j] = j / m;
            else
                dp[0][j] = j / m + 1;
        }
        for (int i=1; i<=a; ++i) {
            for (int j=1; j<=b; ++j) {
                int n1 = DP(i-x, j), n2 = DP(i, j-x), n3 = DP(i-y, j-y);
                dp[i][j] = Math.min(n1, Math.min(n2, n3)) + 1;
            }
        }
        return dp[a][b];
    }

    public static int DP(int i, int j) {
        if (i < 0 && j < 0)
            return 0;
        if (i < 0)
            return dp[0][j];
        if (j < 0)
            return dp[i][0];
        return dp[i][j];
    }
}